<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use \app\service\UrlService;
$this->title = '批卷';
$states =['未批','已批'];
$statecolor = ['red','green'];
?>
<style type="text/css">
	.red{
		background: #ff6c3f;
		color:white;
		padding:3px;
		border-radius:3px;
	}
	.green{
		background: #038000;
		color:white;	
		padding:3px;
		border-radius:3px;
	}
</style>

<table class="table">
  <caption>班级试卷</caption>
  <thead>
    <tr>
      <th>id</th>
      <th>试卷id</th>
      <th>学生id</th>
      <th>批改状态</th>
      <th>班级id</th>
      <th>试卷提交时间</th>
      <th>操作</th>

    </tr>
  </thead>
  <tbody>
    <?php if(empty($classid_papers)): ?>
        <h1>:)</h1><h4>老师辛苦了，没有需要批改的试卷。试卷已全部批改完成</h4>
    <?php endif;?>
  	<?php foreach($classid_papers as $key => $value): ?>
    <tr>
     <td><?=$value['id'];  ?></td>
     <td id="paperid"><?=$value['paperid'];  ?></td>
     <td><?=$value['tid'];  ?></td>
     <td><span class="<?= $statecolor[$value['state']] ?>"><?=$states[$value['state']];  ?></span></td>
     <td><?=$value['classid'];  ?></td>
     <td><?=$value['create_time'];  ?></td>
     <td><button class="btn btn-info" data-id="<?=$value['id'];?>" onclick='pijuan(this)'>查看试卷</button></td>
    </tr>
	<?php endforeach; ?>
  </tbody>
</table>
 <script>
   
	  function pijuan(obj){
	  	var id = obj.dataset.id;
	  	var pid = $(obj).closest('tr').find('td[id=paperid]').text();

	  	window.location.href="<?=UrlService::BuildUrl('/admin/examination/pijuan');?>?id="+id+"&pid="+pid;
	  }

   
</script>